package me.baicai.modules.belldandy.gcb.repository;

import com.alibaba.fastjson.JSONObject;
import me.baicai.modules.belldandy.gcb.domain.Project;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;


/**
* @author 超级大白菜
* @date 2020-03-31
*/
public interface ProjectRepository extends JpaRepository<Project, Integer>, JpaSpecificationExecutor<Project> {
    Project findProjectById(Integer id);

    @Query(value = "select ifnull(sum(orderamount),0) as orderamount,ifnull(sum(profitamount),0) as profitamount from crm_order where projectid = ?1",nativeQuery = true)
    JSONObject getData(Integer projectid);
}
